<template>
  <view class="product-like" v-if="like && like.length > 0">
    <!--<view class="title">- 猜你喜欢 -</view>-->
    <view class="title-x">
      <u--image width="300rpx" height="90rpx" :src="baseUrl + '/mini/bg/recommend.png'"
        lazy-load :fade="true" duration="450" />
    </view>
    <v-product-list :list="like" />
  </view>
</template>

<script>
import config from '../../config/config'
import ProductList from '../product-list/index'
import base64 from '../../util/base64'
import Product from '../../api/product'
const productModel = new Product()
export default {
  components: {
    'v-product-list': ProductList
  },
  data() {
    return {
      like: [],
      baseUrl: config.baseUrl,
    }
  },
  methods: {
    fetchData() {
      /**
       * 后台推荐的商品, 50个
       */
      productModel.like().then(response => {
        let { data } = response
        data = base64.parse(data)
        this.like = data
        // console.log(data)
      })
    }
  },
  created() {
    // 让它比购物车加载迟点
    setTimeout(() => {
      this.fetchData()
    }, 50)
  }
}
</script>

<style scoped lang="scss">
.product-like {
  .title {
    text-align: center;
    height: 70rpx;
    line-height: 70rpx;
    padding-top: 30rpx;
    font-weight: 700;
    font-size: 32rpx;
    color: $main_color;
  }
  .title-x {
    padding-top: 100rpx;
    display: flex;
    justify-content: center;
  }
}
</style>
